home *** CD-ROM | disk | FTP | other *** search
- {
- This is a simple DLL that uses the "status object" in "statobj" to display
- a "status" dialog box. This example simply counts for 5 seconds, allowing
- the user to cancel during that time.
- }
- LIBRARY statdll;
-
- USES
- wintypes, winprocs, wincrt, strings, statobj;
-
- FUNCTION Task_Stat(myhwnd : hwnd) : integer; EXPORT;
- {
- Count for 5 seconds, allowing the user to cancel.
- }
-
- CONST
- stop_at = 5; {seconds to run}
-
- VAR
- all_done, {indicates completion}
- good_finish : boolean; {indicates successful completion}
- curcnt, {current millisecond count}
- startcnt : longint; {count at beginning of loop}
- curperc : REAL; {current percentage}
- tmps, tmps2 : ARRAY [0..20] OF char;
- mystat : stat_dlg;
-
- BEGIN {Task_Stat}
-
- {initialize variables}
- Task_Stat := 0;
- good_finish := false;
-
- IF mystat.init(myhwnd) THEN
- BEGIN
- {initialize and begin loop}
- startcnt := GetTickCount;
- all_done := false;
- WHILE (NOT all_done) DO
- BEGIN
- IF mystat.cancelled THEN
- all_done := true
- ELSE
- BEGIN
- {***
- for file conversion, place the record conversion part here
- ***}
- {increment the count}
- curcnt := GetTickCount - startcnt;
- curperc := 100.0 * (curcnt / (stop_at * 1000.0));
- IF (curcnt >= (stop_at * 1000)) THEN
- {the task has been completed successfully}
- good_finish := true
- ELSE
- {the task is still in progress - update the display}
- BEGIN
- str(round(curcnt / 10.0):1, tmps2);
- strcopy(tmps, 'Count: ');
- strcat(tmps, tmps2);
- mystat.update(curperc, tmps);
- END; {else}
- END;
-
- {conditions for ending: cancelled or finished}
- all_done := all_done OR good_finish;
- END; {while}
-
- mystat.done;
- END; {if}
-
- {if successfully completed, return "-1" (true)}
- IF good_finish THEN
- Task_Stat := -1;
-
- END; {Task_Stat}
-
- EXPORTS
- Task_Stat index 1;
-
- BEGIN {statdll}
- END. {statdll}